<template>
  <div>
    <el-form
      class="form"
      label-position="left"
      :model="form"
      :rules="rules"
      ref="form"
    >
      <el-form-item prop="order_id" label="订单号" style="width: 80px">
        <el-input
          v-model="form.order_id"
          style="width: 180px"
          placeholder="无法修改！"
        ></el-input>
      </el-form-item>
      <el-form-item prop="user_id" label="用户ID" style="width: 80px">
        <el-input
          v-model="form.user_id"
          style="width: 180px"
          type="text"
          placeholder="不允许修改！"
        ></el-input>
      </el-form-item>
      <el-form-item prop="line_id" label="线路ID" style="width: 80px">
        <el-input
          v-model="form.line_id"
          placeholder="请输入"
        ></el-input>
      </el-form-item>
      <el-form-item label="下单时间"  style="width: 100px">
        <el-input v-model="form.ordered_time" placeholder="请输入" style="width: 150px"></el-input>
        <!-- <el-date-picker v-model="form.ordered_time" type="date" value-format="yyyy-MM-dd"
        placeholder="选择日期">
        </el-date-picker> -->
      </el-form-item>
      <el-form-item style="width: 100px" label="总价"> 
        <el-input v-model="form.total_price" type="text" placeholder="请修改"></el-input>
      </el-form-item>
      <el-form-item style="width:100px">
          <el-button
          type="primary"
          style="width: 100%"
          @click="edit()"
        >修改</el-button>        
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import myaxios from "../../http/Myaxios";

export default {
  data() {
    return {
      OrderId: "",
      form: {
        order_id: "",
        user_id: "",
        line_id: "",
        ordered_time: null,
        total_price: "",
      },
      rules:{}
    };
  },
  mounted() {
    let id = this.$route.params.order_id;
    this.OrderId = id;
    let params = { orderId: id };
    myaxios.post("http://localhost:3500/orderId", params).then((res) => {
      console.log("订单号查询返回", res);
      this.form = res.data.data[0]
    });
  },
  methods: {
    name() {
      
    },
     edit() {
      console.log('表单内容',this.form);
      // console.log('form表单选择的时间',this.form.ordered_time);
      myaxios.post("http://localhost:3500/order-edit", this.form).then(res =>{
          console.log('修改订单返回',res);
          if (res.data.code === 200) {
            this.$router.push('/home/order-list')
          }
      });
  },
  },
 
};
</script>

<style lang="scss" scoped>
</style>